package Interact;

import java.io.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Interface {
	HttpServletRequest request;
	Writer writer;
	
	public Interface(OutputStream out){
		this(new OutputStreamWriter(out));
	}
	
	public Interface(Writer writer){
		this.writer = writer;
	}	
	
	public Interface(HttpServletRequest req, HttpServletResponse res) throws IOException{
		request = req;
		writer = res.getWriter();
//		response = res;
	}
	
	public void println(Interactable obj) throws IOException{
		obj.display(this);
		print("<br/>");
	}
	
	public void print(Interactable obj) throws IOException{
		if (obj != null) obj.display(this);
	}
	
	public void printf(String format, Object...args) throws IOException{
		writer.write(String.format(format, args));
	}
	
	public void print(String str) throws IOException{
		writer.write(str);
	}
	
	public void println(String str) throws IOException{
		writer.write(str + "<br/>");
	}
	
	public void flush() throws IOException{
		writer.flush();
	}
	
	public String getValue(String key){
		return request.getParameter(key);
	}
	
	public String[] getValues(String key){
		return request.getParameterValues(key);
	}
}







